//从文件中读取数据输出最大值，最小值，平均值,输入新的值，写到文件中，重新计算。
let rf=require("fs");  
let util = require('../util');
let data=rf.readFileSync("./2/2-11data.json","utf-8"); 
data = JSON.parse(data);
function sumArr(target){
    let sum = 0;
    for(let key in target){
        sum+=parseFloat(target[key]);
    }
    return sum;
}
let newData = 0;
while(newData=parseFloat(util.readSyncByfs('请输入新的数字(输入0终止程序)：'))){
    util.log(newData)
    data.inputdata.push(newData);
    if(newData<data.min){
        data.min = newData;
    }else if(newData>data.max){
        data.max = newData
    }
    data.sum+=newData;
    data.arg = data.sum/(data.inputdata.length);
    console.log(data);
    rf.writeFileSync("./2/2-11data.json",JSON.stringify(data),"utf-8")
}

 
